<html>
<head>
  <title>../ex1.c</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<a href="../ex1.c">download the original source code</a>.
<pre>
<a name="line1">  1</a> <font color="#444444">/*
<a name="line2">  2</a>    Example 1
<a name="line3">  3</a> 
<a name="line4">  4</a>    Interface:    Structured interface (Struct)
<a name="line5">  5</a> 
<a name="line6">  6</a>    Compile with: make ex1 (may need to edit HYPRE_DIR in Makefile)
<a name="line7">  7</a> 
<a name="line8">  8</a>    Sample run:   mpirun -np 2 ex1
<a name="line9">  9</a> 
<a name="line10"> 10</a>    Description:  This is a two processor example.  Each processor owns one
<a name="line11"> 11</a>                  box in the grid.  For reference, the two grid boxes are those
<a name="line12"> 12</a>                  in the example diagram in the struct interface chapter
<a name="line13"> 13</a>                  of the User's Manual. Note that in this example code, we have
<a name="line14"> 14</a>                  used the two boxes shown in the diagram as belonging
<a name="line15"> 15</a>                  to processor 0 (and given one box to each processor). The
<a name="line16"> 16</a>                  solver is PCG with no preconditioner.
<a name="line17"> 17</a> 
<a name="line18"> 18</a>                  We recommend viewing examples 1-4 sequentially for
<a name="line19"> 19</a>                  a nice overview/tutorial of the struct interface.
<a name="line20"> 20</a> */</font>
<a name="line21"> 21</a> 
<a name="line22"> 22</a> <font color="0000ff"><strong>#include <font color="#008000">&lt;stdio.h&gt;</font></strong></font>
<a name="line23"> 23</a> 
<a name="line24"> 24</a> <font color="#444444">/* Struct linear solvers header */</font>
<a name="line25"> 25</a> <font color="0000ff"><strong>#include <font color="#008000">&quot;HYPRE_struct_ls.h&quot;</font></strong></font>
<a name="line26"> 26</a> 
<a name="line27"> 27</a> <strong>int</strong> <font color="#2040a0">main</font> <font color="4444FF">(</font><strong>int</strong> <font color="#2040a0">argc</font>, <strong>char</strong> <font color="4444FF">*</font><font color="#2040a0">argv</font><font color="4444FF">[</font><font color="4444FF">]</font><font color="4444FF">)</font>
<a name="line28"> 28</a> <font color="4444FF"><strong>{</strong></font>
<a name="line29"> 29</a>    <strong>int</strong> <font color="#2040a0">i</font>, <font color="#2040a0">j</font>, <font color="#2040a0">myid</font>, <font color="#2040a0">num_procs</font><font color="4444FF">;</font>
<a name="line30"> 30</a> 
<a name="line31"> 31</a>    <font color="#2040a0">HYPRE_StructGrid</font>     <font color="#2040a0">grid</font><font color="4444FF">;</font>
<a name="line32"> 32</a>    <font color="#2040a0">HYPRE_StructStencil</font>  <font color="#2040a0">stencil</font><font color="4444FF">;</font>
<a name="line33"> 33</a>    <font color="#2040a0">HYPRE_StructMatrix</font>   <font color="#2040a0">A</font><font color="4444FF">;</font>
<a name="line34"> 34</a>    <font color="#2040a0">HYPRE_StructVector</font>   <font color="#2040a0">b</font><font color="4444FF">;</font>
<a name="line35"> 35</a>    <font color="#2040a0">HYPRE_StructVector</font>   <font color="#2040a0">x</font><font color="4444FF">;</font>
<a name="line36"> 36</a>    <font color="#2040a0">HYPRE_StructSolver</font>   <font color="#2040a0">solver</font><font color="4444FF">;</font>
<a name="line37"> 37</a> 
<a name="line38"> 38</a>    <font color="#444444">/* Initialize MPI */</font>
<a name="line39"> 39</a>    <font color="#2040a0">MPI_Init</font><font color="4444FF">(</font><font color="4444FF">&amp;</font><font color="#2040a0">argc</font>, <font color="4444FF">&amp;</font><font color="#2040a0">argv</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line40"> 40</a>    <font color="#2040a0">MPI_Comm_rank</font><font color="4444FF">(</font><font color="#2040a0">MPI_COMM_WORLD</font>, <font color="4444FF">&amp;</font><font color="#2040a0">myid</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line41"> 41</a>    <font color="#2040a0">MPI_Comm_size</font><font color="4444FF">(</font><font color="#2040a0">MPI_COMM_WORLD</font>, <font color="4444FF">&amp;</font><font color="#2040a0">num_procs</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line42"> 42</a> 
<a name="line43"> 43</a>    <strong>if</strong> <font color="4444FF">(</font><font color="#2040a0">num_procs</font> <font color="4444FF">!</font><font color="4444FF">=</font> <font color="#FF0000">2</font><font color="4444FF">)</font>
<a name="line44"> 44</a>    <font color="4444FF"><strong>{</strong></font>
<a name="line45"> 45</a>       <strong>if</strong> <font color="4444FF">(</font><font color="#2040a0">myid</font> <font color="4444FF">=</font><font color="4444FF">=</font><font color="#FF0000">0</font><font color="4444FF">)</font> <font color="#2040a0">printf</font><font color="4444FF">(</font><font color="#008000">&quot;Must run with 2 processors!<font color="#77dd77">\n</font>&quot;</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line46"> 46</a>       <font color="#2040a0">MPI_Finalize</font><font color="4444FF">(</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line47"> 47</a> 
<a name="line48"> 48</a>       <strong>return</strong><font color="4444FF">(</font><font color="#FF0000">0</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line49"> 49</a>    <font color="4444FF"><strong>}</strong></font>
<a name="line50"> 50</a> 
<a name="line51"> 51</a>    <font color="#444444">/* 1. Set up a grid. Each processor describes the piece
<a name="line52"> 52</a>       of the grid that it owns. */</font>
<a name="line53"> 53</a>    <font color="4444FF"><strong>{</strong></font>
<a name="line54"> 54</a>       <font color="#444444">/* Create an empty 2D grid object */</font>
<a name="line55"> 55</a>       <font color="#2040a0">HYPRE_StructGridCreate</font><font color="4444FF">(</font><font color="#2040a0">MPI_COMM_WORLD</font>, <font color="#FF0000">2</font>, <font color="4444FF">&amp;</font><font color="#2040a0">grid</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line56"> 56</a> 
<a name="line57"> 57</a>       <font color="#444444">/* Add boxes to the grid */</font>
<a name="line58"> 58</a>       <strong>if</strong> <font color="4444FF">(</font><font color="#2040a0">myid</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">)</font>
<a name="line59"> 59</a>       <font color="4444FF"><strong>{</strong></font>
<a name="line60"> 60</a>          <strong>int</strong> <font color="#2040a0">ilower</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="4444FF">-</font><font color="#FF0000">3</font>,<font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font>, <font color="#2040a0">iupper</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="4444FF">-</font><font color="#FF0000">1</font>,<font color="#FF0000">2</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line61"> 61</a>          <font color="#2040a0">HYPRE_StructGridSetExtents</font><font color="4444FF">(</font><font color="#2040a0">grid</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line62"> 62</a>       <font color="4444FF"><strong>}</strong></font>
<a name="line63"> 63</a>       <strong>else</strong> <strong>if</strong> <font color="4444FF">(</font><font color="#2040a0">myid</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#FF0000">1</font><font color="4444FF">)</font>
<a name="line64"> 64</a>       <font color="4444FF"><strong>{</strong></font>
<a name="line65"> 65</a>          <strong>int</strong> <font color="#2040a0">ilower</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">0</font>,<font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font>, <font color="#2040a0">iupper</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">2</font>,<font color="#FF0000">4</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line66"> 66</a>          <font color="#2040a0">HYPRE_StructGridSetExtents</font><font color="4444FF">(</font><font color="#2040a0">grid</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line67"> 67</a>       <font color="4444FF"><strong>}</strong></font>
<a name="line68"> 68</a> 
<a name="line69"> 69</a>       <font color="#444444">/* This is a collective call finalizing the grid assembly.
<a name="line70"> 70</a>          The grid is now ``ready to be used'' */</font>
<a name="line71"> 71</a>       <font color="#2040a0">HYPRE_StructGridAssemble</font><font color="4444FF">(</font><font color="#2040a0">grid</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line72"> 72</a>    <font color="4444FF"><strong>}</strong></font>
<a name="line73"> 73</a> 
<a name="line74"> 74</a>    <font color="#444444">/* 2. Define the discretization stencil */</font>
<a name="line75"> 75</a>    <font color="4444FF"><strong>{</strong></font>
<a name="line76"> 76</a>       <font color="#444444">/* Create an empty 2D, 5-pt stencil object */</font>
<a name="line77"> 77</a>       <font color="#2040a0">HYPRE_StructStencilCreate</font><font color="4444FF">(</font><font color="#FF0000">2</font>, <font color="#FF0000">5</font>, <font color="4444FF">&amp;</font><font color="#2040a0">stencil</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line78"> 78</a> 
<a name="line79"> 79</a>       <font color="#444444">/* Define the geometry of the stencil. Each represents a
<a name="line80"> 80</a>          relative offset (in the index space). */</font>
<a name="line81"> 81</a>       <font color="4444FF"><strong>{</strong></font>
<a name="line82"> 82</a>          <strong>int</strong> <font color="#2040a0">entry</font><font color="4444FF">;</font>
<a name="line83"> 83</a>          <strong>int</strong> <font color="#2040a0">offsets</font><font color="4444FF">[</font><font color="#FF0000">5</font><font color="4444FF">]</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="4444FF"><strong>{</strong></font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">0</font>,<font color="#FF0000">0</font><font color="4444FF"><strong>}</strong></font>, <font color="4444FF"><strong>{</strong></font><font color="4444FF">-</font><font color="#FF0000">1</font>,<font color="#FF0000">0</font><font color="4444FF"><strong>}</strong></font>, <font color="4444FF"><strong>{</strong></font><font color="#FF0000">1</font>,<font color="#FF0000">0</font><font color="4444FF"><strong>}</strong></font>, <font color="4444FF"><strong>{</strong></font><font color="#FF0000">0</font>,<font color="4444FF">-</font><font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font>, <font color="4444FF"><strong>{</strong></font><font color="#FF0000">0</font>,<font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line84"> 84</a> 
<a name="line85"> 85</a>          <font color="#444444">/* Assign each of the 5 stencil entries */</font>
<a name="line86"> 86</a>          <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">entry</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">entry</font> <font color="4444FF">&lt;</font> <font color="#FF0000">5</font><font color="4444FF">;</font> <font color="#2040a0">entry</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line87"> 87</a>             <font color="#2040a0">HYPRE_StructStencilSetElement</font><font color="4444FF">(</font><font color="#2040a0">stencil</font>, <font color="#2040a0">entry</font>, <font color="#2040a0">offsets</font><font color="4444FF">[</font><font color="#2040a0">entry</font><font color="4444FF">]</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line88"> 88</a>       <font color="4444FF"><strong>}</strong></font>
<a name="line89"> 89</a>    <font color="4444FF"><strong>}</strong></font>
<a name="line90"> 90</a> 
<a name="line91"> 91</a>    <font color="#444444">/* 3. Set up a Struct Matrix */</font>
<a name="line92"> 92</a>    <font color="4444FF"><strong>{</strong></font>
<a name="line93"> 93</a>       <font color="#444444">/* Create an empty matrix object */</font>
<a name="line94"> 94</a>       <font color="#2040a0">HYPRE_StructMatrixCreate</font><font color="4444FF">(</font><font color="#2040a0">MPI_COMM_WORLD</font>, <font color="#2040a0">grid</font>, <font color="#2040a0">stencil</font>, <font color="4444FF">&amp;</font><font color="#2040a0">A</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line95"> 95</a> 
<a name="line96"> 96</a>       <font color="#444444">/* Indicate that the matrix coefficients are ready to be set */</font>
<a name="line97"> 97</a>       <font color="#2040a0">HYPRE_StructMatrixInitialize</font><font color="4444FF">(</font><font color="#2040a0">A</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line98"> 98</a> 
<a name="line99"> 99</a>       <font color="#444444">/* Set the matrix coefficients.  Each processor assigns coefficients
<a name="line100">100</a>          for the boxes in the grid that it owns. Note that the coefficients
<a name="line101">101</a>          associated with each stencil entry may vary from grid point to grid
<a name="line102">102</a>          point if desired.  Here, we first set the same stencil entries for
<a name="line103">103</a>          each grid point.  Then we make modifications to grid points near
<a name="line104">104</a>          the boundary. */</font>
<a name="line105">105</a>       <strong>if</strong> <font color="4444FF">(</font><font color="#2040a0">myid</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">)</font>
<a name="line106">106</a>       <font color="4444FF"><strong>{</strong></font>
<a name="line107">107</a>          <strong>int</strong> <font color="#2040a0">ilower</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="4444FF">-</font><font color="#FF0000">3</font>,<font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font>, <font color="#2040a0">iupper</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="4444FF">-</font><font color="#FF0000">1</font>,<font color="#FF0000">2</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line108">108</a>          <strong>int</strong> <font color="#2040a0">stencil_indices</font><font color="4444FF">[</font><font color="#FF0000">5</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="4444FF"><strong>{</strong></font><font color="#FF0000">0</font>,<font color="#FF0000">1</font>,<font color="#FF0000">2</font>,<font color="#FF0000">3</font>,<font color="#FF0000">4</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font> <font color="#444444">/* labels for the stencil entries -
<a name="line109">109</a>                                                   these correspond to the offsets
<a name="line110">110</a>                                                   defined above */</font>
<a name="line111">111</a>          <strong>int</strong> <font color="#2040a0">nentries</font> <font color="4444FF">=</font> <font color="#FF0000">5</font><font color="4444FF">;</font>
<a name="line112">112</a>          <strong>int</strong> <font color="#2040a0">nvalues</font>  <font color="4444FF">=</font> <font color="#FF0000">30</font><font color="4444FF">;</font> <font color="#444444">/* 6 grid points, each with 5 stencil entries */</font>
<a name="line113">113</a>          <strong>double</strong> <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#FF0000">30</font><font color="4444FF">]</font><font color="4444FF">;</font>
<a name="line114">114</a> 
<a name="line115">115</a>          <font color="#444444">/* We have 6 grid points, each with 5 stencil entries */</font>
<a name="line116">116</a>          <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#2040a0">nvalues</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">+</font><font color="4444FF">=</font> <font color="#2040a0">nentries</font><font color="4444FF">)</font>
<a name="line117">117</a>          <font color="4444FF"><strong>{</strong></font>
<a name="line118">118</a>             <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#2040a0">i</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="#FF0000">4.0</font><font color="4444FF">;</font>
<a name="line119">119</a>             <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">j</font> <font color="4444FF">=</font> <font color="#FF0000">1</font><font color="4444FF">;</font> <font color="#2040a0">j</font> <font color="4444FF">&lt;</font> <font color="#2040a0">nentries</font><font color="4444FF">;</font> <font color="#2040a0">j</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line120">120</a>                <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#2040a0">i</font><font color="4444FF">+</font><font color="#2040a0">j</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="4444FF">-</font><font color="#FF0000">1.0</font><font color="4444FF">;</font>
<a name="line121">121</a>          <font color="4444FF"><strong>}</strong></font>
<a name="line122">122</a> 
<a name="line123">123</a>          <font color="#2040a0">HYPRE_StructMatrixSetBoxValues</font><font color="4444FF">(</font><font color="#2040a0">A</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#2040a0">nentries</font>,
<a name="line124">124</a>                                         <font color="#2040a0">stencil_indices</font>, <font color="#2040a0">values</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line125">125</a>       <font color="4444FF"><strong>}</strong></font>
<a name="line126">126</a>       <strong>else</strong> <strong>if</strong> <font color="4444FF">(</font><font color="#2040a0">myid</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#FF0000">1</font><font color="4444FF">)</font>
<a name="line127">127</a>       <font color="4444FF"><strong>{</strong></font>
<a name="line128">128</a>          <strong>int</strong> <font color="#2040a0">ilower</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">0</font>,<font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font>, <font color="#2040a0">iupper</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">2</font>,<font color="#FF0000">4</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line129">129</a>          <strong>int</strong> <font color="#2040a0">stencil_indices</font><font color="4444FF">[</font><font color="#FF0000">5</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="4444FF"><strong>{</strong></font><font color="#FF0000">0</font>,<font color="#FF0000">1</font>,<font color="#FF0000">2</font>,<font color="#FF0000">3</font>,<font color="#FF0000">4</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line130">130</a>          <strong>int</strong> <font color="#2040a0">nentries</font> <font color="4444FF">=</font> <font color="#FF0000">5</font><font color="4444FF">;</font>
<a name="line131">131</a>          <strong>int</strong> <font color="#2040a0">nvalues</font>  <font color="4444FF">=</font> <font color="#FF0000">60</font><font color="4444FF">;</font> <font color="#444444">/* 12 grid points, each with 5 stencil entries */</font>
<a name="line132">132</a>          <strong>double</strong> <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#FF0000">60</font><font color="4444FF">]</font><font color="4444FF">;</font>
<a name="line133">133</a> 
<a name="line134">134</a>          <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#2040a0">nvalues</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">+</font><font color="4444FF">=</font> <font color="#2040a0">nentries</font><font color="4444FF">)</font>
<a name="line135">135</a>          <font color="4444FF"><strong>{</strong></font>
<a name="line136">136</a>             <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#2040a0">i</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="#FF0000">4.0</font><font color="4444FF">;</font>
<a name="line137">137</a>             <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">j</font> <font color="4444FF">=</font> <font color="#FF0000">1</font><font color="4444FF">;</font> <font color="#2040a0">j</font> <font color="4444FF">&lt;</font> <font color="#2040a0">nentries</font><font color="4444FF">;</font> <font color="#2040a0">j</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line138">138</a>                <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#2040a0">i</font><font color="4444FF">+</font><font color="#2040a0">j</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="4444FF">-</font><font color="#FF0000">1.0</font><font color="4444FF">;</font>
<a name="line139">139</a>          <font color="4444FF"><strong>}</strong></font>
<a name="line140">140</a> 
<a name="line141">141</a>          <font color="#2040a0">HYPRE_StructMatrixSetBoxValues</font><font color="4444FF">(</font><font color="#2040a0">A</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#2040a0">nentries</font>,
<a name="line142">142</a>                                         <font color="#2040a0">stencil_indices</font>, <font color="#2040a0">values</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line143">143</a>       <font color="4444FF"><strong>}</strong></font>
<a name="line144">144</a> 
<a name="line145">145</a>       <font color="#444444">/* Set the coefficients reaching outside of the boundary to 0 */</font>
<a name="line146">146</a>       <strong>if</strong> <font color="4444FF">(</font><font color="#2040a0">myid</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">)</font>
<a name="line147">147</a>       <font color="4444FF"><strong>{</strong></font>
<a name="line148">148</a>          <strong>double</strong> <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#FF0000">3</font><font color="4444FF">]</font><font color="4444FF">;</font>
<a name="line149">149</a>          <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#FF0000">3</font><font color="4444FF">;</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line150">150</a>             <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#2040a0">i</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="#FF0000">0.0</font><font color="4444FF">;</font>
<a name="line151">151</a>          <font color="4444FF"><strong>{</strong></font>
<a name="line152">152</a>             <font color="#444444">/* values below our box */</font>
<a name="line153">153</a>             <strong>int</strong> <font color="#2040a0">ilower</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="4444FF">-</font><font color="#FF0000">3</font>,<font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font>, <font color="#2040a0">iupper</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="4444FF">-</font><font color="#FF0000">1</font>,<font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line154">154</a>             <strong>int</strong> <font color="#2040a0">stencil_indices</font><font color="4444FF">[</font><font color="#FF0000">1</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="4444FF"><strong>{</strong></font><font color="#FF0000">3</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line155">155</a>             <font color="#2040a0">HYPRE_StructMatrixSetBoxValues</font><font color="4444FF">(</font><font color="#2040a0">A</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#FF0000">1</font>,
<a name="line156">156</a>                                            <font color="#2040a0">stencil_indices</font>, <font color="#2040a0">values</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line157">157</a>          <font color="4444FF"><strong>}</strong></font>
<a name="line158">158</a>          <font color="4444FF"><strong>{</strong></font>
<a name="line159">159</a>             <font color="#444444">/* values to the left of our box */</font>
<a name="line160">160</a>             <strong>int</strong> <font color="#2040a0">ilower</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="4444FF">-</font><font color="#FF0000">3</font>,<font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font>, <font color="#2040a0">iupper</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="4444FF">-</font><font color="#FF0000">3</font>,<font color="#FF0000">2</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line161">161</a>             <strong>int</strong> <font color="#2040a0">stencil_indices</font><font color="4444FF">[</font><font color="#FF0000">1</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="4444FF"><strong>{</strong></font><font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line162">162</a>             <font color="#2040a0">HYPRE_StructMatrixSetBoxValues</font><font color="4444FF">(</font><font color="#2040a0">A</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#FF0000">1</font>,
<a name="line163">163</a>                                            <font color="#2040a0">stencil_indices</font>, <font color="#2040a0">values</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line164">164</a>          <font color="4444FF"><strong>}</strong></font>
<a name="line165">165</a>          <font color="4444FF"><strong>{</strong></font>
<a name="line166">166</a>             <font color="#444444">/* values above our box */</font>
<a name="line167">167</a>             <strong>int</strong> <font color="#2040a0">ilower</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="4444FF">-</font><font color="#FF0000">3</font>,<font color="#FF0000">2</font><font color="4444FF"><strong>}</strong></font>, <font color="#2040a0">iupper</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="4444FF">-</font><font color="#FF0000">1</font>,<font color="#FF0000">2</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line168">168</a>             <strong>int</strong> <font color="#2040a0">stencil_indices</font><font color="4444FF">[</font><font color="#FF0000">1</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="4444FF"><strong>{</strong></font><font color="#FF0000">4</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line169">169</a>             <font color="#2040a0">HYPRE_StructMatrixSetBoxValues</font><font color="4444FF">(</font><font color="#2040a0">A</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#FF0000">1</font>,
<a name="line170">170</a>                                            <font color="#2040a0">stencil_indices</font>, <font color="#2040a0">values</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line171">171</a>          <font color="4444FF"><strong>}</strong></font>
<a name="line172">172</a>       <font color="4444FF"><strong>}</strong></font>
<a name="line173">173</a>       <strong>else</strong> <strong>if</strong> <font color="4444FF">(</font><font color="#2040a0">myid</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#FF0000">1</font><font color="4444FF">)</font>
<a name="line174">174</a>       <font color="4444FF"><strong>{</strong></font>
<a name="line175">175</a>          <strong>double</strong> <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#FF0000">4</font><font color="4444FF">]</font><font color="4444FF">;</font>
<a name="line176">176</a>          <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#FF0000">4</font><font color="4444FF">;</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line177">177</a>             <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#2040a0">i</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="#FF0000">0.0</font><font color="4444FF">;</font>
<a name="line178">178</a>          <font color="4444FF"><strong>{</strong></font>
<a name="line179">179</a>             <font color="#444444">/* values below our box */</font>
<a name="line180">180</a>             <strong>int</strong> <font color="#2040a0">ilower</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">0</font>,<font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font>, <font color="#2040a0">iupper</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">2</font>,<font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line181">181</a>             <strong>int</strong> <font color="#2040a0">stencil_indices</font><font color="4444FF">[</font><font color="#FF0000">1</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="4444FF"><strong>{</strong></font><font color="#FF0000">3</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line182">182</a>             <font color="#2040a0">HYPRE_StructMatrixSetBoxValues</font><font color="4444FF">(</font><font color="#2040a0">A</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#FF0000">1</font>,
<a name="line183">183</a>                                            <font color="#2040a0">stencil_indices</font>, <font color="#2040a0">values</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line184">184</a>          <font color="4444FF"><strong>}</strong></font>
<a name="line185">185</a>          <font color="4444FF"><strong>{</strong></font>
<a name="line186">186</a>             <font color="#444444">/* values to the right of our box */</font>
<a name="line187">187</a>             <strong>int</strong> <font color="#2040a0">ilower</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">2</font>,<font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font>, <font color="#2040a0">iupper</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">2</font>,<font color="#FF0000">4</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line188">188</a>             <strong>int</strong> <font color="#2040a0">stencil_indices</font><font color="4444FF">[</font><font color="#FF0000">1</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="4444FF"><strong>{</strong></font><font color="#FF0000">2</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line189">189</a>             <font color="#2040a0">HYPRE_StructMatrixSetBoxValues</font><font color="4444FF">(</font><font color="#2040a0">A</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#FF0000">1</font>,
<a name="line190">190</a>                                            <font color="#2040a0">stencil_indices</font>, <font color="#2040a0">values</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line191">191</a>          <font color="4444FF"><strong>}</strong></font>
<a name="line192">192</a>          <font color="4444FF"><strong>{</strong></font>
<a name="line193">193</a>             <font color="#444444">/* values above our box */</font>
<a name="line194">194</a>             <strong>int</strong> <font color="#2040a0">ilower</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">0</font>,<font color="#FF0000">4</font><font color="4444FF"><strong>}</strong></font>, <font color="#2040a0">iupper</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">2</font>,<font color="#FF0000">4</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line195">195</a>             <strong>int</strong> <font color="#2040a0">stencil_indices</font><font color="4444FF">[</font><font color="#FF0000">1</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="4444FF"><strong>{</strong></font><font color="#FF0000">4</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line196">196</a>             <font color="#2040a0">HYPRE_StructMatrixSetBoxValues</font><font color="4444FF">(</font><font color="#2040a0">A</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#FF0000">1</font>,
<a name="line197">197</a>                                            <font color="#2040a0">stencil_indices</font>, <font color="#2040a0">values</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line198">198</a>          <font color="4444FF"><strong>}</strong></font>
<a name="line199">199</a>          <font color="4444FF"><strong>{</strong></font>
<a name="line200">200</a>             <font color="#444444">/* values to the left of our box
<a name="line201">201</a>                (that do not border the other box on proc. 0) */</font>
<a name="line202">202</a>             <strong>int</strong> <font color="#2040a0">ilower</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">0</font>,<font color="#FF0000">3</font><font color="4444FF"><strong>}</strong></font>, <font color="#2040a0">iupper</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">0</font>,<font color="#FF0000">4</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line203">203</a>             <strong>int</strong> <font color="#2040a0">stencil_indices</font><font color="4444FF">[</font><font color="#FF0000">1</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="4444FF"><strong>{</strong></font><font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line204">204</a>             <font color="#2040a0">HYPRE_StructMatrixSetBoxValues</font><font color="4444FF">(</font><font color="#2040a0">A</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#FF0000">1</font>,
<a name="line205">205</a>                                            <font color="#2040a0">stencil_indices</font>, <font color="#2040a0">values</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line206">206</a>          <font color="4444FF"><strong>}</strong></font>
<a name="line207">207</a>       <font color="4444FF"><strong>}</strong></font>
<a name="line208">208</a> 
<a name="line209">209</a>       <font color="#444444">/* This is a collective call finalizing the matrix assembly.
<a name="line210">210</a>          The matrix is now ``ready to be used'' */</font>
<a name="line211">211</a>       <font color="#2040a0">HYPRE_StructMatrixAssemble</font><font color="4444FF">(</font><font color="#2040a0">A</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line212">212</a>    <font color="4444FF"><strong>}</strong></font>
<a name="line213">213</a> 
<a name="line214">214</a>    <font color="#444444">/* 4. Set up Struct Vectors for b and x.  Each processor sets the vectors
<a name="line215">215</a>       corresponding to its boxes. */</font>
<a name="line216">216</a>    <font color="4444FF"><strong>{</strong></font>
<a name="line217">217</a>       <font color="#444444">/* Create an empty vector object */</font>
<a name="line218">218</a>       <font color="#2040a0">HYPRE_StructVectorCreate</font><font color="4444FF">(</font><font color="#2040a0">MPI_COMM_WORLD</font>, <font color="#2040a0">grid</font>, <font color="4444FF">&amp;</font><font color="#2040a0">b</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line219">219</a>       <font color="#2040a0">HYPRE_StructVectorCreate</font><font color="4444FF">(</font><font color="#2040a0">MPI_COMM_WORLD</font>, <font color="#2040a0">grid</font>, <font color="4444FF">&amp;</font><font color="#2040a0">x</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line220">220</a> 
<a name="line221">221</a>       <font color="#444444">/* Indicate that the vector coefficients are ready to be set */</font>
<a name="line222">222</a>       <font color="#2040a0">HYPRE_StructVectorInitialize</font><font color="4444FF">(</font><font color="#2040a0">b</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line223">223</a>       <font color="#2040a0">HYPRE_StructVectorInitialize</font><font color="4444FF">(</font><font color="#2040a0">x</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line224">224</a> 
<a name="line225">225</a>       <font color="#444444">/* Set the vector coefficients */</font>
<a name="line226">226</a>       <strong>if</strong> <font color="4444FF">(</font><font color="#2040a0">myid</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">)</font>
<a name="line227">227</a>       <font color="4444FF"><strong>{</strong></font>
<a name="line228">228</a>          <strong>int</strong> <font color="#2040a0">ilower</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="4444FF">-</font><font color="#FF0000">3</font>,<font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font>, <font color="#2040a0">iupper</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="4444FF">-</font><font color="#FF0000">1</font>,<font color="#FF0000">2</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line229">229</a>          <strong>double</strong> <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#FF0000">6</font><font color="4444FF">]</font><font color="4444FF">;</font> <font color="#444444">/* 6 grid points */</font>
<a name="line230">230</a> 
<a name="line231">231</a>          <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#FF0000">6</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line232">232</a>             <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#2040a0">i</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="#FF0000">1.0</font><font color="4444FF">;</font>
<a name="line233">233</a>          <font color="#2040a0">HYPRE_StructVectorSetBoxValues</font><font color="4444FF">(</font><font color="#2040a0">b</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#2040a0">values</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line234">234</a> 
<a name="line235">235</a>          <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#FF0000">6</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line236">236</a>             <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#2040a0">i</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="#FF0000">0.0</font><font color="4444FF">;</font>
<a name="line237">237</a>          <font color="#2040a0">HYPRE_StructVectorSetBoxValues</font><font color="4444FF">(</font><font color="#2040a0">x</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#2040a0">values</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line238">238</a>       <font color="4444FF"><strong>}</strong></font>
<a name="line239">239</a>       <strong>else</strong> <strong>if</strong> <font color="4444FF">(</font><font color="#2040a0">myid</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#FF0000">1</font><font color="4444FF">)</font>
<a name="line240">240</a>       <font color="4444FF"><strong>{</strong></font>
<a name="line241">241</a>          <strong>int</strong> <font color="#2040a0">ilower</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">0</font>,<font color="#FF0000">1</font><font color="4444FF"><strong>}</strong></font>, <font color="#2040a0">iupper</font><font color="4444FF">[</font><font color="#FF0000">2</font><font color="4444FF">]</font><font color="4444FF">=</font><font color="4444FF"><strong>{</strong></font><font color="#FF0000">2</font>,<font color="#FF0000">4</font><font color="4444FF"><strong>}</strong></font><font color="4444FF">;</font>
<a name="line242">242</a>          <strong>double</strong> <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#FF0000">12</font><font color="4444FF">]</font><font color="4444FF">;</font> <font color="#444444">/* 12 grid points */</font>
<a name="line243">243</a> 
<a name="line244">244</a>          <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#FF0000">12</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line245">245</a>             <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#2040a0">i</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="#FF0000">1.0</font><font color="4444FF">;</font>
<a name="line246">246</a>          <font color="#2040a0">HYPRE_StructVectorSetBoxValues</font><font color="4444FF">(</font><font color="#2040a0">b</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#2040a0">values</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line247">247</a> 
<a name="line248">248</a>          <strong>for</strong> <font color="4444FF">(</font><font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">&lt;</font> <font color="#FF0000">12</font><font color="4444FF">;</font> <font color="#2040a0">i</font> <font color="4444FF">+</font><font color="4444FF">+</font><font color="4444FF">)</font>
<a name="line249">249</a>             <font color="#2040a0">values</font><font color="4444FF">[</font><font color="#2040a0">i</font><font color="4444FF">]</font> <font color="4444FF">=</font> <font color="#FF0000">0.0</font><font color="4444FF">;</font>
<a name="line250">250</a>          <font color="#2040a0">HYPRE_StructVectorSetBoxValues</font><font color="4444FF">(</font><font color="#2040a0">x</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#2040a0">values</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line251">251</a>       <font color="4444FF"><strong>}</strong></font>
<a name="line252">252</a> 
<a name="line253">253</a>       <font color="#444444">/* This is a collective call finalizing the vector assembly.
<a name="line254">254</a>          The vectors are now ``ready to be used'' */</font>
<a name="line255">255</a>       <font color="#2040a0">HYPRE_StructVectorAssemble</font><font color="4444FF">(</font><font color="#2040a0">b</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line256">256</a>       <font color="#2040a0">HYPRE_StructVectorAssemble</font><font color="4444FF">(</font><font color="#2040a0">x</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line257">257</a>    <font color="4444FF"><strong>}</strong></font>
<a name="line258">258</a> 
<a name="line259">259</a>    <font color="#444444">/* 5. Set up and use a solver (See the Reference Manual for descriptions
<a name="line260">260</a>       of all of the options.) */</font>
<a name="line261">261</a>    <font color="4444FF"><strong>{</strong></font>
<a name="line262">262</a>       <font color="#444444">/* Create an empty PCG Struct solver */</font>
<a name="line263">263</a>       <font color="#2040a0">HYPRE_StructPCGCreate</font><font color="4444FF">(</font><font color="#2040a0">MPI_COMM_WORLD</font>, <font color="4444FF">&amp;</font><font color="#2040a0">solver</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line264">264</a> 
<a name="line265">265</a>       <font color="#444444">/* Set some parameters */</font>
<a name="line266">266</a>       <font color="#2040a0">HYPRE_StructPCGSetTol</font><font color="4444FF">(</font><font color="#2040a0">solver</font>, <font color="#FF0000">1.0e-06</font><font color="4444FF">)</font><font color="4444FF">;</font> <font color="#444444">/* convergence tolerance */</font>
<a name="line267">267</a>       <font color="#2040a0">HYPRE_StructPCGSetPrintLevel</font><font color="4444FF">(</font><font color="#2040a0">solver</font>, <font color="#FF0000">2</font><font color="4444FF">)</font><font color="4444FF">;</font> <font color="#444444">/* amount of info. printed */</font>
<a name="line268">268</a> 
<a name="line269">269</a>       <font color="#444444">/* Setup and solve */</font>
<a name="line270">270</a>       <font color="#2040a0">HYPRE_StructPCGSetup</font><font color="4444FF">(</font><font color="#2040a0">solver</font>, <font color="#2040a0">A</font>, <font color="#2040a0">b</font>, <font color="#2040a0">x</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line271">271</a>       <font color="#2040a0">HYPRE_StructPCGSolve</font><font color="4444FF">(</font><font color="#2040a0">solver</font>, <font color="#2040a0">A</font>, <font color="#2040a0">b</font>, <font color="#2040a0">x</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line272">272</a>    <font color="4444FF"><strong>}</strong></font>
<a name="line273">273</a> 
<a name="line274">274</a>    <font color="#444444">/* Free memory */</font>
<a name="line275">275</a>    <font color="#2040a0">HYPRE_StructGridDestroy</font><font color="4444FF">(</font><font color="#2040a0">grid</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line276">276</a>    <font color="#2040a0">HYPRE_StructStencilDestroy</font><font color="4444FF">(</font><font color="#2040a0">stencil</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line277">277</a>    <font color="#2040a0">HYPRE_StructMatrixDestroy</font><font color="4444FF">(</font><font color="#2040a0">A</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line278">278</a>    <font color="#2040a0">HYPRE_StructVectorDestroy</font><font color="4444FF">(</font><font color="#2040a0">b</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line279">279</a>    <font color="#2040a0">HYPRE_StructVectorDestroy</font><font color="4444FF">(</font><font color="#2040a0">x</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line280">280</a>    <font color="#2040a0">HYPRE_StructPCGDestroy</font><font color="4444FF">(</font><font color="#2040a0">solver</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line281">281</a> 
<a name="line282">282</a>    <font color="#444444">/* Finalize MPI */</font>
<a name="line283">283</a>    <font color="#2040a0">MPI_Finalize</font><font color="4444FF">(</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line284">284</a> 
<a name="line285">285</a>    <strong>return</strong> <font color="4444FF">(</font><font color="#FF0000">0</font><font color="4444FF">)</font><font color="4444FF">;</font>
<a name="line286">286</a> <font color="4444FF"><strong>}</strong></font>

</pre>
<hr>
syntax highlighted by <a href="http://www.palfrader.org/code2html">Code2HTML</a>, v. 0.9.1
</body>
</html>
